package com.shmn.gongjiajumain.controller;

import com.shmn.common.utils.PageUtils;
import com.shmn.common.utils.R;
import com.shmn.gongjiajumain.entity.JigEntityEntity;
import com.shmn.gongjiajumain.service.JigEntityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 记录工夹具实体信息
 *
 * @author chenshun
 * @email 1005074582@qq.com
 * @date 2023-05-14 16:40:28
 */
@RestController
@RequestMapping("gongjiajumain/jig_detail")
public class jig_detail {
    @Autowired
    private JigEntityService jigEntityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("gongjiajumain:jigentity:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = jigEntityService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{code}")
    //@RequiresPermissions("gongjiajumain:jigentity:info")
    public R info(@PathVariable("code") String code){
		JigEntityEntity jigEntity = jigEntityService.getById(code);

        return R.ok().put("jigEntity", jigEntity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("gongjiajumain:jigentity:save")
    public R save(@RequestBody JigEntityEntity jigEntity){
		jigEntityService.save(jigEntity);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("gongjiajumain:jigentity:update")
    public R update(@RequestBody JigEntityEntity jigEntity){
		jigEntityService.updateById(jigEntity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("gongjiajumain:jigentity:delete")
    public R delete(@RequestBody String[] codes){
		jigEntityService.removeByIds(Arrays.asList(codes));

        return R.ok();
    }

}
